﻿Imports VPager.Enumerations
Imports System.Runtime.Serialization

Namespace Display

    <DataContract()> _
    Public Class DisplayParams
        Private mViewState As AbledState = Nothing
        Private mForceDisable As Boolean = False
        Private mIsValid As Boolean = False

        <IgnoreDataMember()>
        Public Property ViewState() As AbledState
            Get
                Return mViewState
            End Get
            Set(ByVal value As AbledState)
                mViewState = value
            End Set
        End Property

        ''' <summary>
        ''' Determines if Display should be disabled even if there are currently
        ''' PageItems being displayed.
        ''' </summary>
        ''' <returns>True to Force the Disable ViewState otherwise False</returns>
        ''' <remarks>Applicable only if ViewState is set to DISABLE</remarks>
        <DataMember()> _
        Public Property ForceDisable() As Boolean
            Get
                Return mForceDisable
            End Get
            Set(ByVal value As Boolean)
                mForceDisable = value
            End Set
        End Property

        ' Used only for Web Serialization
        <DataMember(Name:="ViewState")> _
        Private Property _ViewState() As String
            Get
                Return mViewState.ToString
            End Get
            Set(ByVal value As String)
                Try
                    Dim state As AbledState = CType([Enum].Parse(GetType(AbledState), value, True), AbledState)
                    If [Enum].IsDefined(GetType(AbledState), state) Then
                        mViewState = state
                        mIsValid = True
                    Else
                        mIsValid = False
                    End If
                Catch ex As ArgumentException
                    mIsValid = False
                End Try
            End Set
        End Property

        Public ReadOnly Property IsValid() As Boolean
            Get
                Return mIsValid
            End Get
        End Property

    End Class

End Namespace

